package com.rxnetwork.sample.login;

import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import com.rxnetwork.bus.RxBus;
import com.rxnetwork.sample.R;
import com.rxnetwork.sample.mvp.MVPBaseActivity;

public class LoginActivity extends MVPBaseActivity<LoginContract.MyView, LoginPresenter> implements LoginContract.MyView {

    private TextView mUserName;
    private TextView mPassword;

    @Override
    protected int getContentViewResId() {
        return R.layout.login;
    }

    @Override
    protected void initViewsAndEvents() {
        //不设置，默认白色
//        setTopBarLayoutColor(getResources().getColor(R.color.color_ffffff));

        mUserName = (TextView) findViewById(R.id.username);
        mPassword = (TextView) findViewById(R.id.password);

        mPresenter.showLoading();
        mPresenter.login(mUserName.getText().toString(), mPassword.getText().toString());

        RxBus.getInstance().send("rxbusTag", "消息实体");
    }

    @Override
    protected CharSequence getTopTitle() {
        return "Test标题";
    }

    @Override
    public void loginSuccess(Object user) {
        Log.i("test1234", mPresenter.toString());
        mPresenter.hideLoading();
        Toast.makeText(this, "user:" + user.toString(), Toast.LENGTH_SHORT).show();

    }

    @Override
    public void loginFailed(String message) {
        mPresenter.hideLoading();
        Toast.makeText(this, "msg:" + message, Toast.LENGTH_SHORT).show();
    }

}
